package it.polito.connectedcar.vehicle;

import it.polito.connectedcar.tcc.zone.Token;

import java.awt.geom.Point2D;

/**
 * This class is a proxy toward the implementation of the source vehicle.
 * Simulation objects or real interface must have an implementation of this
 * class in order to be used by higher level's logic. SourceVehicleProxy models
 * the most important and used parameters' get and set found in the vehicle.
 * 
 * In order to add new functionalities( access other parameter in the real
 * vehicle interface , the corresponding proxy method must be added here in this
 * class , and all the implementations will need to override it.
 * 
 * @author Nicola Aresta
 * 
 */
public abstract class SourceVehicleProxy {

    private VehicleUpdateDelegate delegate;

    public void setVehicleUpdateDelegate(VehicleUpdateDelegate delegate) {
	this.delegate = delegate;
    }

    /**
     * The VehicleUpdateDelegate will be called whenever the sourceInterface
     * changes some of the declared parameter. The changes will be proxied
     * toward the delegate so that he can take further decisions
     * 
     * @return
     */
    public VehicleUpdateDelegate getVehicleUpdateDelegate() {
	return this.delegate;
    }

    /**
     * Impose the speed to the vehicle
     * 
     * @param speed
     *            (m/s)
     */
    public abstract void setSpeed(double speed);

    /**
     * Impose the vehicle a certain speed for an amount of time
     * 
     * @param speed
     *            (m/s)
     * @param duration
     *            (seconds)
     */
    public abstract void slowDown(float speed, int duration);

    /**
     * The Vehicle owns an Identifier which can be used to provide authenticity
     * and integrity to the communication towards the TCC and the vehicles
     * 
     * @return
     */
    public abstract Token getVehicleIdentificationNumber();

    /**
     * Speed in m/s
     * 
     * @return
     */
    public abstract double getSpeed();

    /**
     * direction angle expressed in degrees from magnetic north
     * 
     * @return
     */
    public abstract double getDirection();

    /**
     * UTM coordinates in the local field
     * 
     * @return
     */
    public abstract Point2D getPosition();

    /**
     * current lane identifier the vehicle is into
     * 
     * @return
     */
    public abstract String getCurrentLaneId();

    /**
     * the time expressed in the vehicle reference system
     * 
     * @return
     */
    public abstract long getCurrentTime();
}
